#!/usr/bin/env python
# @Date    : 2023-02-10
# @Author  : Bright (brt2@qq.com)
# @Link    : https://gitee.com/brt2
# @Version : 0.1.0

from mkm import load_mkm_as_km, MkmParseError

def run_check(path_file):
    try:
        load_mkm_as_km(path_file)
    except MkmParseError as e:
        print("[!]", e)


if __name__ == "__main__":
    def getopt():
        import argparse

        parser = argparse.ArgumentParser("mkm格式检测")
        parser.add_argument("-p", "--path", action="store", help="mkm文件路径")
        return parser.parse_args()

    #####################################################################
    args = getopt()

    if args.path:
        run_check(args.path)
    else:
        path = input("\n请输入待处理文件path(支持直接拖拽): ")
        while True:
            run_check(path)

            path = input("继续输入path，按[Q]退出: ")
            if path.lower() == "q":
                break
